package com.bjpowernode.controller;

import com.bjpowernode.pojo.Admin;
import com.bjpowernode.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping("/admin")
public class AdminAction  {

    //在controller层一定会有service层的对象
@Autowired
    AdminService adminService;


    // 实现登陆的判断与相应的跳转
    @RequestMapping("/login")
public String login(String name,String pwd,HttpServletRequest request){

        Admin admin = adminService.login(name, pwd);
        if(admin!=null){
            request.setAttribute("admin",admin );
            return "main";
        }else {
            request.setAttribute("errmsg","账号或密码错误" );
            return "login";
        }



    }



}
